package cn.openea.perpartner.meily.web.controller;

import cn.openea.perpartner.common.auth.entity.LoginBody;
import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.meily.util.UserContext;
import cn.openea.perpartner.meily.web.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;


/**
 */
@Slf4j
@Controller
public class SysIndexController extends BaseController {

    @Autowired
    private IUserService userService;
    @RequestMapping("/")
    public String index(Model model, HttpServletRequest request) {
        //1.获取用户登录信息
        LoginBody loginUser = UserContext.getLoginUser();
        if(!userService.checkUserHasLoginRole(loginUser.getUserid())){
            return "failure";
        }
        model.addAttribute("loginUser", loginUser);
        return "index";
    }

}
